package edu.scau.pos.domain;

import edu.scau.core.Enum.ColorEnum;
import edu.scau.core.Enum.SizeEnum;
import edu.scau.pos.vo.ProductVo;
import edu.scau.sku.domain.Sku;
import edu.scau.sku.domain.SkuColorSize;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
@Data
@Tag(name = "商品详情表",description = "销售模块的商品信息")
public class Product implements Serializable {
    private static final long serialVersionUID = 1L;
    @Schema(name = "productId",description = "商品自增标识ID",type = "Long")
    private long productId;
    @Schema(name = "productSn",description = "商品唯一标识",type = "String")
    private String productSn;
    @Schema(name = "productName",description = "商品名称",type = "String")
    private String productName;
    @Schema(name = "size",description = "商品尺寸信息",implementation = SizeEnum.class)
    private String size;
    @Schema(name = "color",description = "商品颜色信息",implementation = ColorEnum.class)
    private String color;
    @Schema(name = "price",description = "商品单价信息",type = "double")
    private double price;
    @Schema(name = "url",description = "商品图片链接信息",type = "String")
    private String url;
    @Schema(name = "categoryId", description = "商品所属分类",type = "Long")
    private Long categoryId;
    @Schema(name = "category", description = "商品所属分类",implementation = Category.class)
    private Category category;
    @Schema(name = "skuCode",description = "该商品对应的库存信息",type = "String")
    private String skuCode;
    @Schema(name = "sku",description = "该商品对应的库存信息",implementation = Sku.class)
    private Sku sku;
    @Schema(name = "SkuColorSize",description = "该商品对应的库存信息",implementation = SkuColorSize.class)
    private SkuColorSize skuColorSize;
    @Schema(name = "desc",description = "商品详情描述",type = "String")
    private String desc;
    @Schema(name = "isDeleted",description = "逻辑删除 (0: 未删除, 1: 已删除)",type = "int")
    private int isDeleted;
    @Schema(name = "createTime",description = "商品创建时间",type = "Date")
    private Date createTime;
    @Schema(name = "createBy",description = "商品创建人信息",type = "String")
    private String createBy;
    @Schema(name = "updateTime",description = "商品更新时间",type = "Date")
    private Date updateTime;
    @Schema(name = "updateBy",description = "商品更新者信息",type = "String")
    private String updateBy;

    public Product(long productId, String productSn, String productName, String size, String color, Long categoryId, Category category, String skuCode, Sku sku, SkuColorSize skuColorSize, String desc, int isDeleted, Date createTime, String createBy, Date updateTime, String updateBy) {
        this.productId = productId;
        this.productSn = productSn;
        this.productName = productName;
        this.size = size;
        this.color = color;
        this.categoryId = categoryId;
        this.category = category;
        this.skuCode = skuCode;
        this.sku = sku;
        this.skuColorSize = skuColorSize;
        this.desc = desc;
        this.isDeleted = isDeleted;
        this.createTime = createTime;
        this.createBy = createBy;
        this.updateTime = updateTime;
        this.updateBy = updateBy;
    }

    public Product() {
    }

    public Product(ProductVo productVo) {
        if(productVo == null){
            return;
        }
        this.productId = productVo.getProductId();
        this.productSn = productVo.getProductSn();
        this.productName = productVo.getProductName();
        this.size = productVo.getSize();
        this.color = productVo.getColor();
        this.price=productVo.getPrice();
        this.url=productVo.getUrl();
//        this.skuColorSize = productVo.getSkuColorSize();
        this.desc = productVo.getDesc();
        this.categoryId=productVo.getCategoryId();
        this.skuCode=productVo.getSkuCode();
        if(productVo.getCategoryVo()!=null)
        this.category=new Category(productVo.getCategoryVo());
        if(productVo.getSkuVo()!=null)
        this.sku=new Sku(productVo.getSkuVo());
    }
}
